<?php

namespace App\Store\Validate\Goods\GoodsSend;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class GoodsSendgoods extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];
    

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {//新增
            $this->rule = [
                'store_id'=>'required|integer|gt:0',
                'goods_sn_code'=>'required',
                'sendgoods_name'=>'required',
                'count'=>'required|integer|gt:0',
                'pieceprice'=>'required|integer|gt:0',
            ];
            $this->message = [
                'store_id.required' => '门店未选择',
                'store_id.integer' => '门店参数错误',
                'store_id.gt' => '门店参数错误',
                'sendgoods_name.required' => '赠品名称未填写',
                'pieceprice.required' => '成本单价不能为空',
                'pieceprice.integer' => '成本单价需大于0',
                'pieceprice.gt' => '成本单价需大于0',
                'count.required' => '商品数量未填写',
                'count.integer' => '商品数量参数错误',
                'count.gt' => '商品数量参数错误',
            ];
                
        } elseif ($doaction == 'edit') {//编辑单条数据
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'goods_sn_code'=>'required',
                'sendgoods_name'=>'required',
                'count'=>'required|integer|gt:0',
                'pieceprice'=>'required|integer|gt:0',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'sendgoods_name.required' => '赠品名称未填写',
                'pieceprice.required' => '成本单价不能为空',
                'pieceprice.integer' => '成本单价需大于0',
                'pieceprice.gt' => '成本单价需大于0',
                'count.required' => '商品数量未填写',
                'count.integer' => '商品数量参数错误',
                'count.gt' => '商品数量参数错误',
            ];
        } elseif ($doaction == 'dodistribution') {//调拨
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'target_store_id'=>'required|integer|gt:0',
                'count'=>'required|integer|gt:0',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'target_store_id.required' => '目的门店不能为空',
                'target_store_id.integer' => '目的门店参数错误',
                'target_store_id.gt' => '目的门店参数错误',
                'count.required' => '调拨数量未填写',
                'count.integer' => '调拨数量参数错误',
                'count.gt' => '调拨数量需大于0',
            ];
        } elseif ($doaction == 'dodistributionmore') {//调拨
            $this->rule = [
                'target_store_id'=>'required|integer|gt:0',
                'sendgoodslist'=>'required',
            ];
            $this->message = [
                'target_store_id.required' => '目的门店不能为空',
                'target_store_id.integer' => '目的门店参数错误',
                'target_store_id.gt' => '目的门店参数错误',
                'sendgoodslist.required' => '调拨商品不能为空',
            ];
        }
    }
}
